import axios from "@/api/axios";

// 登录
export const getLogin = (data) => {
  return axios.request({
    url: "login",
    method: "POST",
    data,
  });
};
// 文章分类接口
// 文章分类列表
export const getArticles = (data) => {
  return axios.request({
    url: "articles",
    method: "GET",
    params: data,
  });
};
// 用户
export const getArticlesuser = () => {
  return axios.request({
    url: "articlesuser",
    method: "GET",
  });
};
// 添加分类
export const postArticles = (data) => {
  return axios.request({
    url: "articles",
    method: "POST",
    data,
  });
};
// 分类详情
export const getArticlesItem = (id) => {
  return axios.request({
    url: "articles/" + id,
    method: "GET",
  });
};
// 修改详情
export const putArticlesItem = (id, data) => {
  return axios.request({
    url: "articles/" + id,
    method: "Put",
    data,
  });
};

// 删除分类
export const deleteArticlesById = (id) => {
  return axios.request({
    url: "articles/" + id,
    method: "DELETE",
  });
};

// 文章详情接口
// 文章列表
export const getArticlesItems = (data) => {
  return axios.request({
    url: "article-items",
    method: "GET",
    params: data,
  });
};
// 文章分类列表
export const getArticlesList = () => {
  return axios.request({
    url: "articleList",
    method: "GET",
  });
};
// 添加文章
export const postArticlesItem = (data) => {
  return axios.request({
    url: "article-items",
    method: "POST",
    data,
  });
};
// 文章详情
export const getArticlesItemById = (id) => {
  return axios.request({
    url: "article-items/" + id,
    method: "GET",
  });
};
// 修改详情
export const putArticlesItemById = (id, data) => {
  return axios.request({
    url: "article-items/" + id,
    method: "Put",
    data,
  });
};
// 删除分类
export const deleteArticlesItemById = (id) => {
  return axios.request({
    url: "article-items/" + id,
    method: "DELETE",
  });
};
// 文章图片上传
export const imgUpload = (data) => {
  return axios.request({
    url: "upload/img",
    method: "POST",
    data,
  });
};
// 文章图片删除
export const deleteImg = (data) => {
  return axios.request({
    url: "remove/img",
    method: "POST",
    data: data,
  });
};

// 用户接口
// 用户列表
export const getUsers = (data) => {
  return axios.request({
    url: "users",
    method: "GET",
    params: data,
  });
};
// 添加用户
export const postUsers = (data) => {
  return axios.request({
    url: "users",
    method: "POST",
    data,
  });
};
// 用户详情
export const getUserById = (id) => {
  return axios.request({
    url: "users/" + id,
    method: "GET",
  });
};
// 修改用户详情
export const putUserById = (id, data) => {
  return axios.request({
    url: "users/" + id,
    method: "Put",
    data,
  });
};
// 删除用户
export const deleteUserById = (id) => {
  return axios.request({
    url: "users/" + id,
    method: "DELETE",
  });
};

// 视频接口
export const getVideos = (data) => {
  return axios.request({
    url: "videos",
    method: "GET",
    params: data,
  });
};
// 添加视频
export const postVideos = (data) => {
  return axios.request({
    url: "videos",
    method: "POST",
    data,
  });
};
// 视频上传
export const uploadVideos = (data, config) => {
  return axios.request({
    url: "upload/video",
    method: "POST",
    data,
    config,
  });
};
// 视频详情
export const getVideosById = (id) => {
  return axios.request({
    url: "videos/" + id,
    method: "GET",
  });
};
// 修改视频详情
export const putVideoById = (id, data) => {
  return axios.request({
    url: "videos/" + id,
    method: "Put",
    data,
  });
};
// 删除用户
export const deleteVideoById = (id) => {
  return axios.request({
    url: "videos/" + id,
    method: "DELETE",
  });
};

